package parroty;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import services.TagParticipantService;

import com.google.gdata.util.ServiceException;

public class CheckTagsAndParticipantsServlet extends HttpServlet {
	
	private TagParticipantService tagParticipantService = new TagParticipantService();   
	
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		if(req.getParameter("tags") != null && req.getParameter("participants") != null  && req.getParameter("idViewer") != null  ){
			PrintWriter out = resp.getWriter();
			
			try {
				
				String emailInput  = req.getParameter("idViewer").replace("googlewave.com", "gmail.com"); 
				boolean result = tagParticipantService.isContentOfBlipValidWithParticipants(req.getParameter("tags"), req.getParameter("participants"),emailInput); 
				System.out.println(result);
				out.println(result);
		
			} catch (ServiceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
			
		}
		
	}
	
}
